<?php
/*
 */

m2import('dba/udba.o.inc.php');

class phpinchains_util_db_DataSource
{
    
    var $dba;
    var $validators;
    
    function phpinchains_util_db_DataSource()
    {
        if (!defined("MODEL2_DBCONF")) {
            if ($GLOBALS['udba'])
                $this->dba = & $GLOBALS['udba'];
            else
                print 'MODEL2_DBCONF not specified and no existing connection found!';
        } else {
            include(MODEL2_DBCONF);
//            $dbhost='localhost';
//            $dbusr='root';
//            $dbpass='suckpurki';
//            $dbase='xicspro';
//            $tableforwarder='xics';
	        $this->dba = new udba($dbase,$dbhost,$dbusr,$dbpass,$tableforwarder,$dbencoding);
        }
        $ctx = & phpinchains_ApplicationContext::getInstance();
        if ($ctx->getModuleBaseDir())
            include($ctx->getModuleBaseDir().'action-config.xml.php');
        $this->validators = $validators;
    }

    function & getInstance()
    {
        static $obj = null;
        if ($obj == null)
            $obj = new phpinchains_util_db_DataSource();
        return $obj;
    }
    
    function & getConnection()
    {
        return $this->dba;
    }

}

?>
